package by.koleda.photoupdater.fragment;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import by.koleda.photoupdater.R;
import by.koleda.photoupdater.SuggestionsActivity;

public class SyncDialogFragment extends DialogFragment {

	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		
		AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
		builder.setTitle(R.string.sync_title)
			   .setItems(R.array.sync_array, new DialogInterface.OnClickListener() {
				
				@Override
				public void onClick(DialogInterface dialog, int which) {
					dialog.dismiss();
					switch (which) {
						case 0: {
							Intent intent = new Intent(getActivity(), SuggestionsActivity.class);
							intent.putExtra(SuggestionsActivity.POINTS_TAG, 5);
							getActivity().startActivityForResult(intent, 0);
							break;
						}
						
						case 1: {
							Intent intent = new Intent(getActivity(), SuggestionsActivity.class);
							intent.putExtra(SuggestionsActivity.POINTS_TAG, 3);
							getActivity().startActivityForResult(intent, 1);
							break;
						}
						
						case 2: {
							Intent intent = new Intent(getActivity(), SuggestionsActivity.class);
							intent.putExtra(SuggestionsActivity.POINTS_TAG, 0);
							getActivity().startActivityForResult(intent, 2);
							break;
						}
						default: {
							
						}
					}
					
				}
			});
		
		return builder.create();
	}
}
